;
cmedit.SendTaskDemo = (function($, window, document) {
    var thisContext;
    var resourceType="1";
    var privilegeInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.privilegeInfo));
    var leftType="1";
    var mainIsDeleted=1;
    var tabActivelist=[];
    var loadTimeout = cmedit.global.loadTimeout;
    var privilegeIds=window.sessionStorage.getItem(cmedit.global.privilegeIds);
    var userColumnIds=window.sessionStorage.getItem(cmedit.global.userColumnIds);
    var allColumnIds = window.sessionStorage.getItem(cmedit.global.allColumnIds);
    var columnInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.columnInfo));
    var allColumnInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.allColumnInfo));
    var bigColumnId = window.sessionStorage.getItem(cmedit.global.bigColumnId);
    var creImportTaskFlag = window.sessionStorage.getItem(cmedit.global.creImportTaskFlag);
    var checkAllStatus = false;// (版本对比模态框)全选状态
    var topUtil;  //顶层工具类
    var imgList={};
    var selectIds=[];
    var selectColumnIds=[];
    var listTotalCount;
    var listPageSize;
    var singleMainGuid;
	var SendTaskDemoClass = function(){
	    	
	    }
	SendTaskDemoClass.prototype = {
    	constructor : SendTaskDemoClass,
    		
        initHeader : function() {
        	thisContext = this;
        	topUtil = window.parent.cmedit.global;
			thisContext.init();
           
        },
        /**
         * 真正的初始化方法
         */
        init : function(loginModel){
        	thisContext.initViewStyle();
        	thisContext.initColumn();
        	thisContext.initData();
        	thisContext.initEvent();
        },
        /**
         * 初始化页面视图
         */
        initViewStyle : function() {
        	// 如果用户没有签发权限，禁用签发任务页
        	if(privilegeIds.indexOf(cmedit.global.privilegeDistribute) == -1){
        		$("#distributeButton").css('display','none');
        	}
        	// 如果用户没有下载权限，禁用下载按钮
        	if(privilegeIds.indexOf(cmedit.global.privilegeExportword) == -1){
        		$("#downloadButton").hide();
        	}
        	// 如果用户没有删除全部权限，禁用删除按钮
        	if(privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) == -1){
        		$("#deleteButton").hide();
        	}
        	
        	/*$('.re-content').css('height',$(document).height()-110+'px');*/
            $('.re_contleft .slimScrollDiv').css('height',$(document).height()-136+'px');
            $('.tab-content').css('height',$('.portlet-body').innerHeight()-40+'px');
            $('.line-body').css('height',$('.cont_container').innerHeight()-203+'px');

            /*修改滚动条样式*/
            var linescroll_height=$('.line-body').height();
            thisContext.scrollType('.line-body',linescroll_height);
            
            var versionscroll_height=$('.versionContainer').css('maxHeight');
            thisContext.scrollType('.versionContainer',versionscroll_height);
            
            $('#startTime').datepicker({clearBtn: true,format: 'yyyy-mm-dd',autoclose: true});
            $('#endTime').datepicker({clearBtn: true,format: 'yyyy-mm-dd',autoclose: true});
        },
        /**
         * 初始化数据
         */
        initData : function(startPage) {
        	$('#allSelected').prop('checked',false);
        	$('#manuscripyBody').html(cmedit.global.loaderHtml);
        	selectIds=[];
        	if($('#searchContent').val()!=null && $('#searchContent').val()!=''){
        		var title=$('#searchContent').val();
        	}else{
        		var title='';
        	}
        	if($('#endTime').val()!=null && $('#endTime').val()!=''){
        		var dateranges=$("#startTime").val()+" - "+$("#endTime").val();
        	}else{
        		var dateranges='';
        	}
        	var page=startPage?startPage:"1";
        	var states=$(".container_buttons button[class*='active']").attr("states");
        	resourceType=resourceType?resourceType:'1';
        	//判断权限中是否有终审浏览权限，如果有，则显示终审浏览
        	for(var i = 0;i<privilegeInfo.length;i++ ){
				if(privilegeInfo[i].id == "PID_CMEDIT_FINALCENSOR"){
					resourceType = '0';
				}
			}
        	mainIsDeleted=mainIsDeleted?mainIsDeleted:'1';
        	var columnId=$("#preReportColumn").val()!=""?$("#preReportColumn").val():"";
        	var datalist={
        			resourceType:2,
            		mainIsDeleted:1,
            		userColumnIds:userColumnIds,
            		currentPage:page,
            		pageSize:'10',
            		mainHeader:title,
            		mainStatus:2,
            		columnId:columnId,
            		dateranges:dateranges,
            		mainType:0
        	};
        	topUtil.ajaxRequest({
				type: "post",
				async: false,
				dataType: "json",
				url: cmedit.global.cmsPath+"CreImportController/getCreImportTaskByPage",
				data: datalist,
				success: function(data) {
					if(data.status) {
						console.log(data);
						listTotalCount = data.data.totalCount;
						listPageSize = data.data.pageSize;
						var html=template('manuscriptList',data);
						if(html){
							setTimeout(function(){
								$('#manuscripyBody').html(html);
								// 如果用户没有编辑权限，禁用复制操作按钮
								if(privilegeIds.indexOf(cmedit.global.privilegeWritescripts) == -1){
					        		$(".operateCopyItem").css('display','none');
					        		$(".lineTip").css('display','none');
					        		//如果竟然还没有删除全部权限，那就连删除一切干掉
					        		if(privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) == -1){
					        			$(".operateDeleteItem").css('display','none');
					        			$("#deleteButton").hide();
					        			$("#operateButton").css('display','none');
					        		}
					        	}
							},loadTimeout)
							
						}else{
							setTimeout(function(){
								$('#manuscripyBody').html("<span class='noResults'>暂无数据<span>");
							},loadTimeout)
						}
						$("#pagination").html('');
						thisContext.initPage(data.data.totalPage);
						if(!startPage){
							$('#pagination').whjPaging('setPage',1,data.data.totalPage);
						}
					}else{
						alert(data.msg);
					}
				}
			});
        },
        /**
         * 初始化分页
         */
        initPage : function(totalPage){
        	$("#pagination").whjPaging({
                /*pageSizeOpt: [
                    {'value': 5, 'text': '5/page', 'selected': true},
                    {'value': 10, 'text': '10/page'},
                    {'value': 15, 'text': '15/page'},
                    {'value': 20, 'text': '20/page'}
                ],*/
                totalPage: totalPage,
                showPageNum: 4,
                firstPage: '<i class="iconfont icon-diyiye"></i>',
                previousPage: '<i class="iconfont icon-shangyiye"></i>',
                nextPage: '<i class="iconfont icon-xiayiye"></i>',
                lastPage: '<i class="iconfont icon-weiye"></i>',
                skip: 'skip',
                confirm: 'go',
                refresh: 'refresh',
                totalPageText: 'the total {} pages',
                isShowFL: true,
                isShowPageSizeOpt: false,
                isShowSkip: false,
                isShowRefresh: false,
                isShowTotalPage: false,
                isResetPage: true,
                callBack: function (currPage, pageSize) {
                    thisContext.initData(currPage);
                }
            });
        	/*$('#pagination').whjPaging('setPage',1,totalPage);*/
        },
        /**
         * 初始化事件
         */
        initEvent : function() {
        	
            $('.nav-link').on('click',function () {
                $('.nav-link').removeClass('nav_active');
                $(this).addClass('nav_active');
            });
            
            $('.container_buttons button').on('click',function () {
                $(this).addClass('active').siblings().removeClass('active');
                thisContext.initData();
            });
            
            $('.manu_copy').on('click',function(){
                var tipHeight=$(window).height()-$(this).offset().top;
                if(tipHeight<232){
                    $(this).next().removeClass('dropdown-menutop');
                    $(this).next().addClass('dropdown-menubot');
                }
            });
            
            /**
             * 审核意见改变时，根据审核意见隐藏或者显示指定审核人
             */
            $("input[name='censorType']").on('change',function(){
            	var censorResultType = $("input[name='censorType']:checked").val();
            	if(censorResultType == "3"){
            		$('.checkPeople').hide();
            	}else if(censorResultType == "2"){
            		$('.checkPeople').show();
            	}
            });
            
            $(".modalClose").on('click',function(){
            	thisContext.initModel();
            });
          //时间筛选绑定change事件
			/*$('#endTime').change(function() {
				thisContext.initData();
			});*/
		  //栏目筛选功能
			/*$('#preReportColumn').change(function(){
				thisContext.initData();
			});*/
		  //刷新列表
			$('.manu_refresh').on('click',function(){
				thisContext.clearCondition();
				//thisContext.initData();
			});
			/*$('#confirmCensor').on('click',function(){
				var son = window.top.document.getElementsByName('manuscriptIframe')[0].contentWindow;
				son.cmedit.EditSystem.censorManuscript();
			});*/
			
        },
        /**
         * 清空我的稿件、全部稿件条件选择框
         */
        clearCondition : function(){
        	$("#preReportColumn").val('');
    		$('#searchContent').val('');
    		$("#preReportColumn").selectpicker('refresh');
    		$(".container_buttons button[states='']").addClass('active').siblings().removeClass('active');
    		$('.date-picker input').val('').datepicker('clearDates');
        },
        /**
         * 全选
         */
        allfileSelected : function(){
            if($('#allSelected').prop('checked')){
                $('.select-check').prop('checked',true);
                $('.list_check').addClass('list_checked');
                $('.res-one').addClass('ulChecked');
                selectIds=[];
                for(var i=0;i<$('#manuscripyBody .list_checked').length;i++){
                	selectIds.push($('#manuscripyBody .listone_check').eq(i).attr('id'));
                }
            }else{
                $('.select-check').prop('checked',false);
                $('.list_check').removeClass('list_checked');
                $('.res-one').removeClass('ulChecked');
                selectIds=[];
            }
        },
        
        /**
         * 选择框点击事件
         */
        listOneCheckClick : function(obj,id,columnId){
        	if(!$(obj).prev().prop('checked')){
                $(obj).addClass('list_checked');
                selectIds.push(id);
                selectColumnIds.push(columnId);
                if(listTotalCount >= listPageSize){
                	if($('.list_checked').length >= listPageSize){
                        $('#allSelected').prop('checked',true);
                    }
                }else{
                	if($('#manuscripyBody .list_checked').length == listTotalCount){
                    	$('#allSelected').prop('checked',true);
                    }
                }
            }else{
                $(obj).removeClass('list_checked');
                selectIds.splice($.inArray(id,selectIds),1);
                selectColumnIds.splice($.inArray(id,selectColumnIds),1);
                $('#allSelected').prop('checked',false);
                $('#allSelected').next().removeClass('list_checked');
            }
        },
        
        /**
         * 锁定/解锁稿件
         */
        lockManuscript : function(mainGuid,lockOrUnlock){
        	var flag = false;
        	var postData = {
    			mainGuid :mainGuid,
    			privilegeIds : "",
    			lockOrUnlock : lockOrUnlock,
    		};
        	topUtil.ajaxRequest({
        		type : 'POST',
        		url : cmedit.global.cmsPath + 'ManuscriptMainController/lockOrUnlockManuscript',
        		data : postData,
        		dataType : 'json',
        		async: false,
        		success : function(data) {
        			if (data.status) {
        				flag = true;
        			} else {
        				alert(data.msg);
        				flag = false;
        			}
        		}
        	});
        	return flag;
        },
        /**
         * 重置tab宽度
         */
        resizeTab : function(){
        	var addTabnums=$(".nav-tabs li").length;
        	var maxWidth=($('.nav-tabs').width()-100)/addTabnums-52;
        	console.log(maxWidth);
        	$('.nav-tabs li span').css('maxWidth',maxWidth);
        },
        /**
         *滚动条样式
         */
        scrollType : function(scrollId,scrollHeight) {
            $(scrollId).slimScroll({
                height: scrollHeight,//可滚动区域高度
                size: '5px',//组件宽度
                color: '#999',//滚动条颜色
                railOpacity: .3,//滚动条透明度
                disableFadeOut: true,//鼠标经过可滚动区域时显示组件，离开时隐藏组件
                wheelStep: 20, //滚轮滚动量
                alwaysVisible: true,//始终显示组件
                borderRadius: '7px' //滚动条圆角
            });
        },
        /**
         *列表状态显示
         */
        istatusMouseover : function(e){
        	var tipHeight=$(window).height()-$(e).offset().top;
            console.log(tipHeight);
            if(tipHeight<122){
                $(e).next().removeClass('dropdown_tiptop');
                $(e).next().addClass('dropdown_tipbot');
            }
            /*ManuscriptSystem.isHeight();*/
            $(e).next().show();
        },
        istatusMouseout : function(e){
        	$(e).next().hide();
        },
        
        /**
         * 复制稿件
         * @param mainGuid 稿件主表id
         * @param mainType 复制目标稿件类型 
         * 【0：CMS稿件 1：微信稿 2：微博稿件 3：电视稿件 4：通稿稿件】
         */
        copyManuscript : function(mainGuid, mainType){
        	if(mainType == 0){
        		// 复制为同类稿件
        		topUtil.ajaxRequest({
    				type: "post",
    				async: true,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/copyManuscript",
    				data: {
    					mainGuid : mainGuid
    				},
    				success: function(data) {
    					if(data.status) {
    						var cms = data.data;
    						thisContext.initData();
    						newNotify = $.notify({title:'复制成功[<a class="toCopy" href="javascript:void(0);" onclick="cmedit.SendTaskDemo.switchtoCopyCms(\''+cms.mainGuid+'\',\''+cms.mainHeader+'\');">查看</a>]',message:''},{delay: '5000'});
    					}else{
    						$.notify('复制失败');
    					}
    				}
    			});
        	}else{
        		// 复制为其他类稿件
        		topUtil.ajaxRequest({
    				type: "post",
    				async: true,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/copyManuscriptToOther",
    				data: {
    					mainGuid : mainGuid,
    					targetMainType : mainType
    				},
    				success: function(data) {
    					if(data.status) {
    						thisContext.initData();
    						newNotify = $.notify({title:'复制成功[<a class="toCopy" href="javascript:void(0);" onclick="cmedit.SendTaskDemo.switchtoCopy(\''+data.data+'\',\''+mainType+'\');">查看</a>]',message:''},{delay: '5000'});
    						
    					}else{
    						$.notify('复制失败');
    					}
    				}
    			});
        	}
        },
        /**
         * 跳转到复制的同类稿件
         */
        switchtoCopyCms : function(mainGuid, mainHeader){
        	newNotify.close();
        	cmedit.SendTaskDemo.enterDetail(mainGuid, mainHeader);
        },
        /**
         * 跳转到复制的其他类稿件
         */
        switchtoCopy : function(externalKey,mainType){
        	newNotify.close();
        	// 获取指定跳转的稿件前端地址
        	var appPath = topUtil.getAppPathByType(mainType);
        	var switchHtml = appPath + "?externalKey=" + externalKey;
//        	window.location.href = switchHtml;  //在本窗口跳转
        	window.open(switchHtml);//在新窗口跳转
        },
        
        /**
         * 审核稿件
         */
        censorManuscript : function(){
        	var censorResultType = $("input[name='censorType']:checked").val();
        	var censorOpinion = $("#auditComments").val();
        	var mainGuid = $("#censorMainGuid").val();
        	var fromTask = $("#fromTask").val();// 审核来源（审核列表【manuTask】点开和编辑页面点开）
        	var nominatorId = $("#nextCensor").val();
        	var nominator = $("#nextCensor").find("option:selected").text();
        	var postData = {
        		mainGuid : mainGuid,
        		censorResultType : censorResultType,
        		censorOpinion : censorOpinion,
        		nominatorId : nominatorId,
        		nominator : nominator
        	}
        	topUtil.ajaxRequest({
				type: "post",
				async: false,
				dataType: "json",
				url: cmedit.global.cmsPath+"CmsController/auditManuscript",
				data : postData,
				success: function(data) {
					if(data.status) {
						thisContext.initData();
						thisContext.initModel();
			        	if("manuTask" == fromTask){
			        		var childIframe = $('#iframe_manuTask')[0].contentWindow;
							childIframe.cmedit.TaskSystem.initData();
			        	}else{
			        		var son = window.top.document.getElementsByName('manuscriptIframe')[0].contentWindow;
				        	son.cmedit.EditSystem.initData();
				        	thisContext.removeTab(mainGuid);
			        	}
			        	
					}else{
						console.log(data);
					}
				}
			});
        	
        },
        /**
         * 批量删除
         */
        selectDelect : function(){
        	if(selectIds.length == 0){
        		$.notify("请先选择记录！");
				$('.manuLoader').hide();
				return false;
        	}else{
        		window.parent.cmedit.ManuscriptSystem.delResoure(selectIds,"manuSendTask");
        	}
        	
        },
        /**
         * 删除操作
         */
        delResoure : function(mainGuid,fromIframe){
        	window.parent.cmedit.ManuscriptSystem.delResoure(mainGuid,"manuSendTask");
        },
        
        /**
         * 判断稿件是否锁定
         */
        manuscriptIsLocked : function(manuscriptId){
        	var lockFlag = false;
        	var postData = {
        		mainGuid : manuscriptId
        	}
        	topUtil.ajaxRequest({
				type: "post",
				async: false,
				dataType: "json",
				url: cmedit.global.cmsPath+"ManuscriptMainController/manuscriptIsLocked",
				data: postData,
				success: function(data){
					if(data.status) {
						lockFlag = true;
					}else{
						lockFlag = false;
					}
				}
			});
        	return lockFlag;
        },
        /**
         * 删除签发记录
         * @param mntGuid
         */
        deleteDistribute : function(mntGuid){
        	$('#sendDel').dialogBox({
                type: 'correct',  //three type:'normal'(default),'correct','error',
                width:400,
                height: 200,
                hasMask: true,  //是否显示遮罩层
                hasClose: true,  //是否显示关闭按钮
                hasBtn: true,  //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999,  //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '是否删除签发记录？',
                confirm: function() {
                	var postData = {
                    		"mntGuid" : mntGuid,
                	}
                	topUtil.ajaxRequest({
        				type: "post",
        				async: true,
        				dataType: "json",
        				url: cmedit.global.cmsPath+"ManuscriptNewTargetController/deleteDistribute",
        				data: postData,
        				success: function(data){
        					if(data.status) {
        						$.notify("签发记录删除成功");
        						var iframe_manuSend = window.top.document.getElementById('iframe_manuSend').contentWindow;
        		                iframe_manuSend.cmedit.TargetSystem.init();
        					}else{
        						$.notify(data.msg);
        					}
        				}
        			});
                }
            });
        	/*topUtil.alert(function(flag){
        		if(flag){
        			var postData = {
                    		"mntGuid" : mntGuid,
                    	}
                    	topUtil.ajaxRequest({
            				type: "post",
            				async: true,
            				dataType: "json",
            				url: cmedit.global.releasePath+"ManuscriptNewTargetController/deleteDistribute",
            				data: postData,
            				success: function(data){
            					if(data.status) {
            						alert("签发记录删除成功");
            						thisContext.init();
            					}else{
            						alert("签发记录删除失败");
            					}
            				}
            			});
        		}
        	},"是否删除签发记录")*/
        	
        },
        
        /**
         * 初始化栏目
         */
        initColumn : function(){
        	//判断该成员是否属于大采访部，如果是，则可以显示所有的栏目
        	if(userColumnIds.indexOf(bigColumnId) > 0){
        		for(var i = 0;i < allColumnInfo.length; i++){
            		$("#preReportColumn").append('<option value="'+allColumnInfo[i].id+'">'+allColumnInfo[i].name+'</option>');
            	}
        	}else{
        		for(var i = 0;i < columnInfo.length; i++){
            		$("#preReportColumn").append('<option value="'+columnInfo[i].id+'">'+columnInfo[i].name+'</option>');
            	}
        	}
        	$("#preReportColumn").selectpicker('refresh');
        },
        
        
        /**
         * 详情页
         */
        enterDetail : function(mainGuid,mainHeader){
        	window.parent.cmedit.ManuscriptSystem.enterDetail(mainGuid,mainHeader);
        },
        
        /**
         * 获取稿件签发目标
         */
        getTargetList : function(mainColumnId){
        	var submitMainGuid = $("#submitMainGuid").val();
        	var postData = {
        		mainGuid : submitMainGuid,
        		columnId : mainColumnId,
        	}
        	topUtil.ajaxRequest({
				type: "post",
				async: false,
				dataType: "json",
				url: cmedit.global.cmsPath+"CmsController/getCmsTargetSystem",
				data : postData,
				success: function(data) {
					if(data.status) {
						/*var html=template('targetList',data);
						$("#mainTargetList").html(html);*/
						var html = '';
						var creTargetList = data.data.creTargetList;
						var cmsTargetList = data.data.cmsTargetList;
						for(var i =0;i < creTargetList.length;i++){
							html += '<label class="mt-checkbox mt-checkbox-outline">' +
									'<input type="checkbox" name="targetRadio" value="' + creTargetList[i].creTargetGuid + '"> ' + creTargetList[i].creTargetName + '' + 
									'<span></span>' +
									'</label>';	
						}
						for(var i = 0;i < cmsTargetList.length;i++){
							html += '<label class="mt-checkbox mt-checkbox-outline">' +
							'<input type="checkbox" name="targetRadio" value="' + cmsTargetList[i].cmsTargetGuid + '"> ' + cmsTargetList[i].cmsTargetName + '' + 
							'<span></span>' +
							'</label>';	
						}
						$("#mainTargetList").html(html);
					}else{
						console.log(data)
					}
				}
			});
        },
        /**
         * 打开审核、提交模态框
         */
        taskmodalShow : function(isCheck,isSubmit){
        	if(isCheck == 0){
        		$('#taskmodalDefault .checkPeople').hide();
        		$('#submitModal .checkPeople').hide();
        		$('#taskmodalDefault .modal-body').addClass('noCheck');
        		$('#submitModal .modal-body').addClass('noCheck');
        	}else{
        		
        		if($('#taskmodalDefault .modal-body').hasClass('noCheck')){
        			$('#taskmodalDefault .modal-body').removeClass('noCheck');
        		}
        		if($('#submitModal .modal-body').hasClass('noCheck')){
        			$('#submitModal .modal-body').removeClass('noCheck');
        		}
        		if(privilegeIds.indexOf(cmedit.global.privilegeDistribute) >= 0){
        			$('#taskmodalDefault .checkDistribute').show();
        			$('#submitModal .checkDistribute').show();
        		}else{
        			$('#taskmodalDefault .checkDistribute').hide();
        			$('#submitModal .checkDistribute').hide();
        		}
        	}
        	if(isSubmit){
        		$('#submitModal').modal('show');
        	}else{
        		var censorResultType = $("input[name='censorType']:checked").val();
            	if(censorResultType == "3"){
            		$('#taskmodalDefault .checkPeople').hide();
            		$('#submitModal .checkPeople').hide();
            	}else if(censorResultType == "2"  && isCheck != 0){
            		$('#taskmodalDefault .checkPeople').show();
            		$('#submitModal .checkPeople').show();
            	}
            	
            	var mainGuid = $("#censorMainGuid").val();
            	var postData = {
                		mainGuid : mainGuid
                	}
            	topUtil.ajaxRequest({
    				type: "post",
    				async: false,
    				/*contentType: "application/json;charset=UTF-8",*/
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/getSelectedCmsManuscriptTarget",
    				data : postData,
    				success: function(data) {
    					if(data.status) {
    						var selectedTargetList = data.data;
    						if (selectedTargetList.length > 0) {
    							var html = '';
    							for(var i = 0;i < selectedTargetList.length;i++){
    								html += '<span class="sendGoal">'
    									+ selectedTargetList[i].manuscriptTargetName +  
    									'</span><br/>';	
    							}
    							$("#newTargetList").html(html+"<br/>");
    						}
    						$('#taskmodalDefault').modal('show');
    					}else{
    						console.log(data)
    					}
    				}
    			});
        	}
        },
        
        /**
         * 打开新媒体栏目模态框
         */
        newsModalShow : function(){
        	$('#newsModal').modal('show');
        },
        
        /**
         * 打开版本管理模态框
         */
        versionmodalShow : function(mainGuid){
        	//加载版本数据
        	$("#versionList").html("");
        	$(".noVersion").css("display","block");
        	$(".versionContent").html('<span class="vcontDefault">请在右侧选择对比版本</span>');
        	$("input[type=checkbox].selectAllVersion").prop("checked",false);
        	$("#changeRow").prop("checked",false);
        	if(topUtil.isNotEmpty(mainGuid)){
        		topUtil.ajaxRequest({
    				type: "post",
    				async: false,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"ManuscriptMarkController/getManuscriptMarkList",
    				data : {
    					mainGuid:mainGuid
    				},
    				success: function(data) {
    					if(data.status) {
    						$(".noVersion").css("display","none");
    						var html = template('manuVersionList',data);
    						$("#versionList").html(html);
    						$('#versionModal').modal('show');
    						//为列表复选框绑定事件
    						$(".versionChoose").unbind('click').bind('click',function(event){
    							thisContext.checkAllSelect();
    							thisContext.compareVersion(event);
    						});
    						//为全选按钮绑定事件
    						$(".selectAllVersion").unbind('click').bind('click',function(){
    							var choose = $("input[type=checkbox].selectAllVersion").prop("checked");
    							if(!choose){//当前为选中状态
    								$("input[type=checkbox].versionChoose").prop("checked",false);
    								thisContext.compareVersion(event);
    							}else{//当前为未选中状态
    								$("input[type=checkbox].versionChoose").prop("checked",true);
    								thisContext.compareVersion(event);
    							}
    						});
    					}else{
    						$.notify("获取稿件版本信息失败");
    						$('#versionModal').modal('show');
    					}
    				}
    			});
        	}else{
        		$('#versionModal').modal('show');
        	}
        	
        },
        
        /**
         * 版本对比
         * @param event
         */
        compareVersion : function(event){
			event.stopPropagation();//防止事件冒泡
			var chooseVersions = $("input[type=checkbox]:checked.versionChoose");
			var count = chooseVersions.length;
			if(count >= 1){//不止一个版本被选中时 【2018-2-11修改：选中一个版本时也要显示】
				var markGuids = [];
				var markVersions = [];
				var markColors = [];
				$.each(chooseVersions,function(index,item){
					var markGuid = $(item).parent().attr("id");
					markGuids.push(markGuid);
					markVersions.push($("#"+markGuid+" #markVersion").val());
					markColors.push($("#"+markGuid+" #markColor").val());
				});
				topUtil.ajaxRequest({
					type: "post",
					async: false,
					dataType: "json",
					url: cmedit.global.cmsPath+"ManuscriptMarkController/compareMark",
					data : {
						markGuids:JSON.stringify(markGuids),
						markVersions:JSON.stringify(markVersions),
						markColors:JSON.stringify(markColors)
					},
					success: function(data) {
						if(data.status) {
							$(".versionContent").html(data.data);
							// 自动换行功能产品ayl要求去除(2018-06-22)
							$(".versionContent").attr("style","word-break:break-all;");
						}else{
							$.notify(data.msg);
						}
					}
				});
			}else{
				$(".versionContent").html('<span class="vcontDefault">请在右侧选择对比版本</span>');
			}
        },
        /**
         * 版本对比结果，自动换行功能
         */
        changeRow : function(){
        	if($("#changeRow").is(':checked')){
        		$(".versionContent").attr("style","word-break:break-all;");
        	}else{
        		$(".versionContent").attr("style","word-break:normal;");
        	}
        	
        },
        /**
         * 判断版本对比模态框中的列表 全选状态
         */
        checkAllSelect : function(){
        	// 列表数量
        	var count = $(".versionChoose").length;
        	// 选中的数量
        	var chooseCount = $("input[type=checkbox]:checked.versionChoose").length;
        	if(count == chooseCount){
        		$(".selectAllVersion").prop("checked",true);
        	}else{
        		$(".selectAllVersion").prop("checked",false);
        	}
        },
        
        /**
         * 下载稿件选择
         * @returns {Boolean}
         */
        selectDownload : function(){
        	if(selectIds.length == 0){
        		$.notify("请先选择记录！");
				$('.manuLoader').hide();
				return false;
        	}else if(selectIds.length > 1){
        		$.notify("同时只能下载一条稿件！");
				$('.manuLoader').hide();
				return false;
        	}else{
        		window.parent.cmedit.ManuscriptSystem.showDownloadModal(selectIds);
        	}
        },
        
        /**
         * 删除下载状态记录
         * @param downloadStatusGuid
         */
        delDownlaodResoure : function(downloadStatusGuid){
        	var delFlag = true;
        	var mainGuidlist=[];
        	/*console.log(flag);*/
        	$('#manuscriptDel').dialogBox({
                type: 'correct',  //three type:'normal'(default),'correct','error',
                width:400,
                height: 200,
                hasMask: true,  //是否显示遮罩层
                hasClose: true,  //是否显示关闭按钮
                hasBtn: true,  //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999,  //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '确定要删除该记录？',
                confirm: function() {
                	var downloadStatusGuids = [];
                	downloadStatusGuids.push(downloadStatusGuid);
                	var postData = {
            				"downloadStatusGuids" : JSON.stringify(downloadStatusGuids)
            			};
                	topUtil.ajaxRequest({
        				type: "post",
        				async: true,
        				dataType: "json",
        				url: cmedit.global.cmsPath + "DownloadManageController/deleteDownloadStatus",
        				data: postData,
        				success: function(data) {
        					// 刷新列表
        					var childIframe = $('#iframe_manuDownload')[0].contentWindow;
							childIframe.cmedit.DownloadSystem.initDownloadStatus();
        				}
        			});
                    	
                }
            });
        	
        },
        
        /**
         * 实际签发操作
         * @param columnIds
         */
        distributeTarget : function(targetIds){
        	var postData;
        	var mainGuids = [];
        	//判断是单条记录选择还是勾选的
        	if(topUtil.isNotEmpty(singleMainGuid)){
        		mainGuids.push(singleMainGuid);
        		postData = {
        			targetIds :	JSON.stringify(targetIds),
            		mainGuids : JSON.stringify(mainGuids),
            	}
        		singleMainGuid = '';
        	}else{
        		postData = {
        			targetIds :	JSON.stringify(targetIds),
            		mainGuids : JSON.stringify(selectIds),
            	}
        	}
        	topUtil.ajaxRequest({
				type: "post",
				async: true,
				dataType: "json",
				url: cmedit.global.cmsPath+"CmsNewTargetController/batchDistribute",
				data: postData,
				success: function(data){
					if(data.status) {
						$.notify("签发稿件成功");
						thisContext.initData();
					}else{
						$.notify(data.msg);
					}
				}
			});
        },
        
        /**
         * 签发弹框
         */
        sendTaskModal : function(mainGuid,columnId){
        	debugger
        	if(selectIds.length > 0 || topUtil.isNotEmpty(mainGuid)){
        		var columnIds = [];
        		var mainGuids = [];
        		//判断是单条记录选择的还是勾选的
        		if(topUtil.isNotEmpty(mainGuid)){
        			singleMainGuid = mainGuid;
        			mainGuids.push(mainGuid);
        			columnIds.push(columnId);
        		}else{
        			//如果入库开关开启了，那么进行签发的时候要判断，如果选中的稿件中有未入库成功的，则不能进行签发
        			/*if(creImportTaskFlag == 0){
            			var misStatus;
            			for(var i = 0; i < selectIds.length;i++){
                			misStatus = $("#" + selectIds[i]).attr("status");
                			if(misStatus != 5){
                				$.notify("选中的稿件有未入库成功的，不能进行签发");
                				return;
                			}
                		}
            		}*/
        			columnIds = selectColumnIds;
        			mainGuids = selectIds;
        		}
        		var postData = {
        			columnIds :	JSON.stringify(columnIds),
        			mainGuids : JSON.stringify(mainGuids),
            	}
    		    //获取公共的签发目标
            	topUtil.ajaxRequest({
    				type: "post",
    				async: true,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/getCmsTargetSystemArr",
    				data: postData,
    				success: function(data){
    					if(data.status) {
    						var html = '';
    						var creTargetList = data.data.creTargetList;
    						var cmsTargetList = data.data.cmsTargetList;
    						if (creTargetList.length > 0 || cmsTargetList.length > 0){ 
    							for(var i =0;i < creTargetList.length;i++){
        							html += '<label class="mt-checkbox mt-checkbox-outline">' +
        									'<input type="checkbox" name="targetCheck" id="' + creTargetList[i].creTargetGuid + '"> ' + creTargetList[i].creTargetName + '' + 
        									'<span></span>' +
        									'</label><br/>';	
        						}
        						for(var i = 0;i < cmsTargetList.length;i++){
        							html += '<label class="mt-checkbox mt-checkbox-outline">' +
        							'<input type="checkbox" name="targetCheck" id="' + cmsTargetList[i].cmsTargetGuid + '"> ' + cmsTargetList[i].cmsTargetName + '' + 
        							'<span></span>' +
        							'</label><br/>';	
        						}
        						
        						$("#targetListArr",parent.document).html(html);
        						$("input[name='targetCheck']",parent.document).on('change',function(){
					            	var i = $("input[name='targetCheck']:checked",parent.document).length;
					            	if(i > 0){
					            		$("#confirmDistribute",parent.document).attr("disabled",false);
					            	}else{
					            		$("#confirmDistribute",parent.document).attr("disabled",true);
					            	}
					            });
        						$("#confirmDistribute",parent.document).attr("disabled",true);
        						window.parent.cmedit.ManuscriptSystem.sendTaskModalShow();
    						} else{
    							$("#targetListArr",parent.document).html("无签发目标");
    							$("#confirmDistribute",parent.document).attr("disabled",true);
    							$.notify("无签发目标")
    						}
    						
    					}else{
    						$.notify(data.msg);
    					}
    				}
    			});
        	}else{
        		$.notify("请选择一条稿件进行签发");
        	}
        },
       
        empty : null
    };
	return new SendTaskDemoClass();
})(jQuery, window, document);
//}();
$(cmedit.SendTaskDemo.initHeader());
